
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swipe_action_cell/core/cell.dart';
import 'package:get/get.dart';
import 'package:sp_util/sp_util.dart';
import 'package:yp/Xwidgets/cache_image.dart';
import 'package:yp/config/config.dart';
import 'package:yp/pages/order_create/widgets/specifications_widget.dart';
import 'package:yp/widgets/button_widget.dart';

import '../../../helper.dart';
import '../../../router.dart';
import '../logic.dart';

class ItemWidget2 extends StatefulWidget {
  int shopIndex;
  int goodsListIndex;
  int index;

  final OrderCreateLogic logic;

  ItemWidget2(
      {Key key, this.shopIndex, this.goodsListIndex, this.index, this.logic})
      : super(key: key);

  @override
  _ItemWidget2State createState() => new _ItemWidget2State();
}

class _ItemWidget2State extends State<ItemWidget2> {
  TextEditingController controller = TextEditingController();
  int _sum = 1;
  Map jiaobiao;

  @override
  void initState() {
    super.initState();
    controller.text = widget
        .logic
        .state
        .cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"]
            [widget.goodsListIndex]["items"][widget.index]['quantity']
        .toInt()
        .toString();

    controller.addListener(() {
      if (controller.text.isEmpty || controller.text == "0") {
        controller.text = "1";
      }
    });
    jiaobiao = widget.logic.state.cartData["multi_shop_items"][widget.shopIndex]
        ["cart_item_list"][widget.goodsListIndex]["items"][widget.index];

    // if(jiaobiao !=null){
    // var jiao =  widget.logic.state.promotion_cat['fillet'].split(",");
    //   print('角角角角角角角角角角角角角');
    //     print( widget.logic.state.activity_cat);
    //  }
  }

  void _plus(logic) {
    _sum++;
    var cartId = logic.state.cartData["multi_shop_items"][widget.shopIndex]
            ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
        ['cart_id'];
    var cheaced = logic.state.cartData["multi_shop_items"][widget.shopIndex]
            ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
        ['is_checked'];
    logic.cartItemEdit(cartId, cheaced, _sum);
    // logic.cartGoodsData();
    // logic.update();
    // controller.text = _sum.toString();
    // setState(() {});
  }

  void _reduce(logic) {
    if (_sum != 1) {
      _sum--;
      var cartId = logic.state.cartData["multi_shop_items"][widget.shopIndex]
              ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
          ['cart_id'];
      var cheaced = logic.state.cartData["multi_shop_items"][widget.shopIndex]
              ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
          ['is_checked'];
      logic.cartItemEdit(cartId, cheaced, _sum);
      // controller.text = _sum.toString();
      // logic.update();
    }
    setState(() {});
  }

  void Change(logic, value) {
    var cartId = logic.state.cartData["multi_shop_items"][widget.shopIndex]
            ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
        ['cart_id'];
    var cheaced = logic.state.cartData["multi_shop_items"][widget.shopIndex]
            ["cart_item_list"][widget.goodsListIndex]["items"][widget.index]
        ['is_checked'];

    print(value);
    if (value.toString().isEmpty || value.toString() == "0") return;
    logic.cartItemEdit(cartId, cheaced, value);
    logic.update();
  }

  @override
  Widget build(BuildContext context) {
    Widget jiaobaoWig = Container(
      padding: EdgeInsets.symmetric(horizontal: 5.w, vertical: 5.w),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.only(
            topLeft: Radius.circular(widget.logic.state.cxangle[0]),
            topRight: Radius.circular(widget.logic.state.cxangle[1]),
            bottomLeft: Radius.circular(widget.logic.state.cxangle[2]),
            bottomRight: Radius.circular(widget.logic.state.cxangle[3])),
        border: Border.all(
          color:
              getColorFromHex(widget.logic.state.activity_cat['frame_color']),
          width: 1.w,
        ),
        color: getColorFromHex(widget.logic.state.activity_cat['tag_fgcolor']),
      ),
      child: Text(
        '秒杀',
        style: TextStyle(
          color: getColorFromHex(widget.logic.state.activity_cat['word_color']),
          fontSize: 20.sp,
          height: 1.3,
        ),
      ),
    );

    return Container(
      padding: EdgeInsets.symmetric(
        vertical: 20.w,
      ),
      decoration: BoxDecoration(
        border: Border(
          bottom: BorderSide(
            color: Color(0xfff0f0f0),
          ),
        ),
      ),
      child: GetBuilder<OrderCreateLogic>(builder: (logic) {
        _sum = logic
            .state
            .cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"]
                [widget.goodsListIndex]["items"][widget.index]['quantity']
            .toInt();
        logic.state.number.text = logic
            .state
            .cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"]
                [widget.goodsListIndex]["items"][widget.index]['quantity']
            .toInt()
            .toString();

        controller.text = logic
            .state
            .cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"]
                [widget.goodsListIndex]["items"][widget.index]['quantity']
            .toInt()
            .toString();
        return SwipeActionCell(
          ///这个key是必要的
          key: ObjectKey(logic.state.cartData["multi_shop_items"]
                  [widget.shopIndex]["cart_item_list"][widget.goodsListIndex]
              ["items"][widget.index]),
          trailingActions: <SwipeAction>[
            SwipeAction(
              icon: Icon(
                Icons.delete_forever_outlined,
                color: Colors.white,
              ),
              onTap: (CompletionHandler handler) {
                showDialog(
                    context: context,
                    barrierDismissible: false,
                    builder: (BuildContext context) {
                      return AlertDialog(
                        title: Text('提示'),
                        content: Text('是否删除商品'),
                        actions: <Widget>[
                          FlatButton(
                            onPressed: () => Navigator.of(context).pop(),
                            child: Text('取消'),
                          ),
                          FlatButton(
                            onPressed: () {
                              Navigator.of(context).pop();
                              var params = {
                                "usr_num_id":
                                    logic.state.orderMemberData["empeNumId"],
                                'access_token': SpUtil.getString('token'),
                                "use_platform": 2,
                                "cart_id":
                                    logic.state.cartData["multi_shop_items"]
                                                    [widget.shopIndex]
                                                ["cart_item_list"]
                                            [widget.goodsListIndex]["items"]
                                        [widget.index]["cart_id"],
                              };
                              logic.cartDelete(params);
                              logic.update();
                            },
                            textColor: Colors.red,
                            child: Text('确定'),
                          ),
                        ],
                      );
                    });
                //删除当前项数据

                // logic.state.cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"][widget.goodsListIndex]["items"].entity.removeAt(widget.index);
                // logic.state.cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"][widget.goodsListIndex]["items"].delete(widget.index);
              },
              color: Colors.red,
            ),
          ],
          child: Container(
            color: Colors.white,
            child: Column(
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    GestureDetector(
                      onTap: () {
                        var cartId = logic.state.cartData["multi_shop_items"]
                                    [widget.shopIndex]["cart_item_list"]
                                [widget.goodsListIndex]["items"][widget.index]
                            ['cart_id'];
                        var cheaced = logic.state.cartData["multi_shop_items"]
                                    [widget.shopIndex]["cart_item_list"]
                                [widget.goodsListIndex]["items"][widget.index]
                            ['is_checked'];
                        if (cheaced == 1) {
                          cheaced = 0;
                        } else {
                          cheaced = 1;
                        }

                        logic.cartItemEdit(cartId, cheaced, _sum);
                        // logic.cartGoodsData();
                        logic.update();
                      },
                      child: Container(
                        padding: EdgeInsets.only(right: 20.w),
                        child: Image.asset(
                          logic.state.cartData["multi_shop_items"]
                                                  [widget.shopIndex]
                                              ["cart_item_list"]
                                          [widget.goodsListIndex]["items"]
                                      [widget.index]["is_checked"] ==
                                  1
                              ? "assets/images/selectIcon1.png"
                              : "assets/images/select1.png",
                          width: 50.w,
                        ),
                      ),
                    ),
                    Container(
                        width: 176.w,
                        padding: EdgeInsets.only(right: 16.w),
                        child: Stack(
                          children: [
                            GestureDetector(
                              child: CachedImage(
                                path:
                                    '${logic.state.cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"][widget.goodsListIndex]["items"][widget.index]['image_default_id']}',
                              ),

                              // Image.network(
                              //   "",
                              //   width: 160.w,
                              //   height: 160.w,
                              //   fit: BoxFit.cover,
                              // ),
                              onTap: () {
                                Get.toNamed(RouteConfig.goodsDetail,
                                    arguments: {
                                      'itemNumId': logic
                                          .state
                                          .cartData["multi_shop_items"]
                                              [widget.shopIndex]
                                              ["cart_item_list"]
                                              [widget.goodsListIndex]["items"]
                                              [widget.index]['item_num_id']
                                          .toString(),
                                      'styleNumId': logic
                                          .state
                                          .cartData["multi_shop_items"]
                                              [widget.shopIndex]
                                              ["cart_item_list"]
                                              [widget.goodsListIndex]["items"]
                                              [widget.index]['style_num_id']
                                          .toString(),
                                      // 'shopId': SpUtil.getInt('storeShopNum').toString(),
                                      'shopId': SpUtil.getObject(
                                          Config.GET_SHOP_INFO)['shop_id'],
                                      'ecStyleNumId': logic
                                          .state
                                          .cartData["multi_shop_items"]
                                              [widget.shopIndex]
                                              ["cart_item_list"]
                                              [widget.goodsListIndex]["items"]
                                              [widget.index]['ec_style_num_id']
                                          .toString(),
                                      'typeIndex': logic.state.cartData[
                                                              "multi_shop_items"]
                                                          [widget.shopIndex]
                                                      ["cart_item_list"][
                                                  widget
                                                      .goodsListIndex]["items"]
                                              [widget.index]['is_pre_sale'] ??
                                          0,
                                    });
                              },
                            ),
                          ],
                        )),
                    Expanded(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.start,
                        children: [
                          Row(
                            children: [
                              if (logic.state
                                          .activity_cat['cart_page_position'] ==
                                      '7' &&
                                  logic.state.cartData["multi_shop_items"]
                                                      [widget.shopIndex]
                                                  ["cart_item_list"]
                                              [widget.goodsListIndex]["items"]
                                          [widget.index]['activity_type'] ==
                                      1)
                                jiaobaoWig,
                              Expanded(
                                child: Text(
                                  logic.state.cartData["multi_shop_items"]
                                                  [widget.shopIndex]
                                              ["cart_item_list"]
                                          [widget.goodsListIndex]["items"]
                                      [widget.index]["title"],
                                  style: TextStyle(
                                    color: Color(0xff333333),
                                    fontSize: 28.w,
                                  ),
                                  maxLines: 1,
                                  textAlign: TextAlign.start,
                                  overflow: TextOverflow.ellipsis,
                                ),
                              ),
                            ],
                          ),
                          SizedBox(
                            height: 10.w,
                          ),
                          logic.state.cartData["multi_shop_items"]
                                                  [widget.shopIndex]
                                              ["cart_item_list"]
                                          [widget.goodsListIndex]["items"]
                                      [widget.index]["nospec"] ==
                                  1
                              ? Container(
                                  // height: 35.w,
                                  )
                              : GestureDetector(
                                  onTap: () {
                                    logic.goodsSpecifications(
                                        logic.state.cartData["multi_shop_items"]
                                                        [widget.shopIndex]
                                                    ["cart_item_list"]
                                                [widget.goodsListIndex]["items"]
                                            [widget.index]);
                                    logic.state.goodsNum = _sum;
                                    logic.state.cart_id =
                                        logic.state.cartData["multi_shop_items"]
                                                        [widget.shopIndex]
                                                    ["cart_item_list"]
                                                [widget.goodsListIndex]["items"]
                                            [widget.index]["cart_id"];
                                    logic.state.ec_shop_num_id = logic
                                        .state
                                        .cartData["multi_shop_items"]
                                            [widget.shopIndex]["ec_shop_num_id"]
                                        .toString(); //店铺编码
                                    logic.state.item_num_id = logic
                                        .state
                                        .cartData["multi_shop_items"]
                                            [widget.shopIndex]["cart_item_list"]
                                            [widget.goodsListIndex]["items"]
                                            [widget.index]["item_num_id"]
                                        .toString(); //商品编码
                                    selectProduct(context);
                                  },
                                  child: Container(
                                    padding: EdgeInsets.symmetric(
                                        horizontal: 20.w, vertical: 4.w),
                                    decoration: BoxDecoration(
                                        borderRadius:
                                            BorderRadius.circular(40.w),
                                        border: Border.all(
                                          color: Color(0xffEEEEEE),
                                          width: 2.w,
                                          style: BorderStyle.solid,
                                        )),
                                    child: RichText(
                                      text: TextSpan(
                                        children: [
                                          TextSpan(
                                            text: logic.state.cartData[
                                                                "multi_shop_items"]
                                                            [widget.shopIndex]
                                                        ["cart_item_list"][
                                                    widget
                                                        .goodsListIndex]["items"]
                                                [widget.index]["spec_info"],
                                            style: TextStyle(
                                                color: Color(0xffCCCCCC),
                                                fontSize: 24.w),
                                          ),
                                          WidgetSpan(
                                            child: Padding(
                                              padding: EdgeInsets.only(
                                                  left: 5.w,
                                                  right: 10.w,
                                                  bottom: 3.w),
                                              child: Image(
                                                image: AssetImage(
                                                    "assets/images/icon-down.png"),
                                                width: 24.w,
                                                height: 24.w,
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ),
                                ),
                          SizedBox(
                            height: 10.w,
                          ),
                          if (jiaobiao['item_single_promotion_list'] != null &&
                              jiaobiao['item_single_promotion_list'].length > 0)
                            Container(
                              padding: EdgeInsets.symmetric(
                                  horizontal: 15.w, vertical: 6.w),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.only(
                                    topLeft:
                                        Radius.circular(logic.state.angle[0]),
                                    topRight:
                                        Radius.circular(logic.state.angle[1]),
                                    bottomLeft:
                                        Radius.circular(logic.state.angle[2]),
                                    bottomRight:
                                        Radius.circular(logic.state.angle[3])),
                                border: Border.all(
                                  color: getColorFromHex(
                                      logic.state.promotion_cat['frame_color']),
                                  width: 1.w,
                                ),
                                color: getColorFromHex(
                                    logic.state.promotion_cat['tag_fgcolor']),
                              ),
                              child: Text(
                                // tag_name_type ==1 45 0 一口价
                                logic.state.promotion_cat != null
                                    ? logic.state.promotion_cat[
                                                'tag_name_type'] ==
                                            1
                                        ? "${jiaobiao['item_single_promotion_list'][0]["corner_with_param"]}"
                                        : "${jiaobiao['item_single_promotion_list'][0]["corner_with_no_param"]}"
                                    : '',
                                style: TextStyle(
                                  color: getColorFromHex(
                                      logic.state.promotion_cat['word_color']),
                                  fontSize: 26.sp,
                                  height: 1.3,
                                ),
                              ),
                            ),
                          Container(
                            width: 500.w,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                RichText(
                                  text: TextSpan(
                                    children: [
                                      TextSpan(
                                        text: '￥',
                                        style: TextStyle(
                                            color: Config.mainColor,
                                            fontSize: 24.w),
                                      ),
                                      TextSpan(
                                        text:
                                            "${(logic.state.cartData["multi_shop_items"][widget.shopIndex]["cart_item_list"][widget.goodsListIndex]["items"][widget.index]["price"]).toStringAsFixed(2)}",
                                        style: TextStyle(
                                            color: Config.mainColor,
                                            fontSize: 30.w),
                                      ),
                                    ],
                                  ),
                                ),
                                if (logic.state.activity_cat[
                                            'cart_page_position'] ==
                                        '8' &&
                                    logic.state.cartData["multi_shop_items"]
                                                        [widget.shopIndex]
                                                    ["cart_item_list"]
                                                [widget.goodsListIndex]["items"]
                                            [widget.index]['activity_type'] ==
                                        1)
                                  jiaobaoWig,
                                Container(
                                  child: Row(
                                    children: [
                                      GestureDetector(
                                        onTap: () {
                                          _reduce(logic);
                                        },
                                        child: Image(
                                          image: AssetImage(
                                              "assets/images/reduce.png"),
                                          width: 40.w,
                                        ),
                                      ),
                                      SizedBox(
                                        width: 5.w,
                                      ),
                                      Container(
                                        width: 80.w,
                                        height: 40.w,
                                        child: TextField(
                                          controller: controller,
                                          keyboardType: TextInputType.number,
                                          textAlign: TextAlign.center,
                                          style: TextStyle(fontSize: 12),
                                          enableInteractiveSelection: false,
                                          decoration: InputDecoration(
                                            contentPadding: EdgeInsets.only(
                                                left: 0,
                                                top: 2,
                                                bottom: 2,
                                                right: 0),
                                            border: const OutlineInputBorder(
                                              gapPadding: 0,
                                              borderSide: BorderSide(
                                                width: 0,
                                                style: BorderStyle.none,
                                              ),
                                            ),
                                          ),
                                          inputFormatters: <TextInputFormatter>[
                                            FilteringTextInputFormatter
                                                .digitsOnly,
                                            FilteringTextInputFormatter.allow(
                                                RegExp(r'[0-9]')),
                                          ],
                                          onChanged: (value) {
                                            Change(logic, value);
                                          },
                                        ),
                                      ),
                                      // Text(
                                      //   _sum.toString(),
                                      //   style: TextStyle(
                                      //     fontSize: 28.w,
                                      //     color: Color(0xff333333),
                                      //   ),
                                      // ),
                                      SizedBox(
                                        width: 5.w,
                                      ),
                                      GestureDetector(
                                        onTap: () {
                                          _plus(logic);
                                        },
                                        child: Image(
                                          image: AssetImage(
                                              "assets/images/plus.png"),
                                          width: 40.w,
                                        ),
                                      )
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          ),
                          if (logic.state.activity_cat['cart_page_position'] ==
                                  '9' &&
                              logic.state.cartData["multi_shop_items"]
                                                  [widget.shopIndex]
                                              ["cart_item_list"]
                                          [widget.goodsListIndex]["items"]
                                      [widget.index]['activity_type'] ==
                                  1)
                            jiaobaoWig,
                        ],
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        );
      }),
    );
  }

  //显示底部弹框的功能
  void selectProduct(BuildContext context) {
    //用于在底部打开弹框的效果
    showModalBottomSheet(
        isScrollControlled: true,
        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(10.0.w),
        ),
        builder: (BuildContext contexts) {
          //构建弹框中的内容
          return Container(
            height: 1000.w,
            width: 750.w,
            // decoration: BoxDecoration(
            //   borderRadius: BorderRadius.only(topLeft: Radius.circular(30.w),topRight: Radius.circular(30.w),),
            // ),
            child: Column(
              children: [
                Container(
                  padding: EdgeInsets.symmetric(vertical: 20.w),
                  margin: EdgeInsets.only(right: 22.w, left: 22.w),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border(
                      bottom: BorderSide(
                        color: Color(0xfff0f0f0),
                      ),
                    ),
                  ),
                  child: GetBuilder<OrderCreateLogic>(builder: (logic) {
                    return Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        CachedImage(
                          path: logic.state.goodsSpecificationsImageData,
                          width: 180.w,
                          height: 180.w,
                        ),
                        SizedBox(
                          width: 10.w,
                        ),
                        Expanded(
                          child: Text(
                            logic.state.goodsSpecificationsTitleData,
                            style: TextStyle(
                              color: Color(0xff222222),
                              fontSize: 28.sp,
                            ),
                            maxLines: 2,
                            textAlign: TextAlign.start,
                            overflow: TextOverflow.ellipsis,
                          ),
                        )
                      ],
                    );
                  }),
                ),
                Expanded(
                  child: Container(
                    padding: EdgeInsets.symmetric(vertical: 20.w),
                    margin: EdgeInsets.only(right: 22.w, left: 22.w),
                    width: 710.w,
                    decoration: BoxDecoration(
                      color: Colors.white,
                      border: Border(
                        bottom: BorderSide(
                          color: Color(0xfff0f0f0),
                        ),
                      ),
                    ),
                    child: SingleChildScrollView(
                      child: GetBuilder<OrderCreateLogic>(
                        builder: (logic) {
                          var data =
                              logic.state.goodsSpecificationsData['specs'];
                          int len = 0;
                          if (data != null && data['specs'] != null) {
                            len = data['specs'].length;
                          }
                          ;
                          return ListView.builder(
                            itemBuilder: (ctx, index) {
                              //商品规格列表
                              var data1 =
                                  logic.state.goodsSpecificationsData['specs']
                                      ['specs'][index];
                              //商品规格对应数据
                              var data2 = logic
                                  .state.goodsSpecificationsData['spec_item'];
                              List data1List = data1["spec_values"];
                              return SpecificationsWidget(
                                data: data,
                                data1: data1,
                                data2: data2,
                                data1List: data1List,
                                index: index,
                                // logic: logic,
                              );
                            },
                            itemCount: len,
                            shrinkWrap: true,
                            physics: NeverScrollableScrollPhysics(),
                          );
                        },
                      ),
                    ),
                  ),
                ),
                Container(
                    color: Colors.white,
                    padding: EdgeInsets.symmetric(
                      vertical: 30.w,
                      horizontal: 46.w,
                    ),
                    child: SingleChildScrollView(
                        child: GetBuilder<OrderCreateLogic>(builder: (logic) {
                      return Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            crossAxisAlignment: CrossAxisAlignment.end,
                            children: [
                              Visibility(
                                child: RichText(
                                  text: TextSpan(
                                    children: [
                                      TextSpan(
                                        text:
                                            "￥${(logic.state.sumParic * logic.state.goodsNum).toString()}",
                                        style: TextStyle(
                                            color: Config.mainColor,
                                            fontSize: 40.w),
                                      ),
                                    ],
                                  ),
                                ),
                                visible: logic.state.sumParic != null &&
                                    logic.state.goodsNum != null,
                              ),
                              Container(
                                child: Row(
                                  children: [
                                    GestureDetector(
                                      onTap: () {
                                        _reduce(logic);
                                      },
                                      child: Image(
                                        image: AssetImage(
                                            "assets/images/reduce.png"),
                                        width: 44.w,
                                      ),
                                    ),
                                    SizedBox(
                                      width: 15.w,
                                    ),
                                    Text(
                                      _sum.toString(),
                                      style: TextStyle(
                                        fontSize: 36.w,
                                        color: Color(0xff333333),
                                      ),
                                    ),
                                    SizedBox(
                                      width: 15.w,
                                    ),
                                    GestureDetector(
                                      onTap: () {
                                        _plus(logic);
                                      },
                                      child: Image(
                                        image: AssetImage(
                                            "assets/images/plus.png"),
                                        width: 44.w,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          SizedBox(
                            height: 50.w,
                          ),
                          GestureDetector(
                            onTap: () async {
                              //代客下单该规格先删除商品然后重新增加
                              var params = {
                                "usr_num_id": SpUtil.getInt('empeNumId'),
                                // "emp_num_id": SpUtil.getInt('empeNumId'),
                                "use_platform": 2,
                                "cart_id": logic.state.cart_id,
                                // 'inv_from_type': logic.state.sendType == 1
                                //     ? 3
                                //     : null, //个人仓时传3，非个人仓传2或null
                                'access_token': SpUtil.getString('token'),
                              };
                              await logic.cartDelete(params);
                              //重新增加
                              var params1 = {
                                "use_platform": 2,
                                //app
                                "usr_num_id": SpUtil.getInt('empeNumId'),
                                'access_token': SpUtil.getString('token'),
                                "channel_num_id": 99,
                                //订单渠道：小程序 98，App 99
                                "ec_shop_num_id": logic.state.ec_shop_num_id,
                                //店铺编码
                                "item_num_id": logic.state.item_num_id,
                                //商品编码
                                "quantity": logic.state.goodsNum,
                                //数量
                                'inv_from_type': 2,
                                //个人仓时传3，非个人仓传2或null
                                "style_num_id":
                                    logic.state.goodsSpecificationsData[
                                                "spec_item"]
                                            [logic.state.selectSpecifications]
                                        ["ec_style_num_id"],
                                //款式编码
                                "ec_style_num_id":
                                    logic.state.goodsSpecificationsData[
                                                "spec_item"]
                                            [logic.state.selectSpecifications]
                                        ["ec_style_num_id"],
                                //唯一款式编码
                              };
                              print('params1params1params1');
                              print(params1);
                              logic.addShoppingCart(params1);
                            },
                            child: ButtonWidget(title: "确定"),
                          ),
                        ],
                      );
                    }))),
              ],
            ),
          );
        },
        context: context);
  }
}
